﻿using AutoMapper;

namespace GroceryPriceBook.Core.Mappers
{
	/// <summary>
	/// View Model object for presentation which inherits the AutoMapper Profile class
	/// </summary>
	public class PurchaseLog : Profile
	{
		public override string ProfileName
		{
			get { return "PurchaseLogMappings"; }
		}

		protected override void Configure()
		{
			Mapper.CreateMap<Model.PurchaseLog, ViewModel.PurchaseLog>()
				  .ForMember(dest => dest.StoreId, opt => opt.MapFrom(src => src.Store))
				  .ForMember(dest => dest.Store, opt => opt.MapFrom(src => src.Store1));
			Mapper.CreateMap<ViewModel.PurchaseLog, Model.PurchaseLog>()
				  .ForMember(dest => dest.Store, opt => opt.MapFrom(src => src.StoreId))
				  .ForSourceMember(src => src.Store, opt => opt.Ignore())
				  .ForSourceMember(src => src.PurchaseLogSelectListItems, opt => opt.Ignore());
		}
	}
}
